import config from './config'

var scrollTop = document.documentElement.scrollTop;

window.addEventListener('scroll',()=>{
    scrollTop = document.documentElement.scrollTop;
    config.emitter.emit('get-scrollTop', scrollTop)
    // console.log(scrollTop)
})

const backTop = function () {
    var timer = setInterval(function () {
        var top = document.documentElement.scrollTop;
        var speed = top / 20;
        document.documentElement.scrollTop = top - speed;
        if (top == 0) {
            clearInterval(timer);
        }
    }, 5)
}


export {
    scrollTop,
    backTop
}